package com.fesine.ch02.setNoeStringTwoLock;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2016/7/8 15:26
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/7/8 15:26
 */
public class MyService {
    private String lock = "123";

    public void testMehod() {
        try {
            synchronized (lock) {
                System.out.println(Thread.currentThread().getName() + " begin " +
                        System.currentTimeMillis());
                lock = "456";
                Thread.sleep(2000);
                System.out.println(Thread.currentThread().getName() + " end " +
                        System.currentTimeMillis());

            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
